<?php

namespace app\admin\controller\setting;

use app\admin\controller\AdminController;
use app\admin\service\setting\ExportService;
use think\response\Json;

/**
 * 导出日志
 */
class Export extends AdminController
{
    /**
     * 查看导出日志列表
     * @return Json
     */
    public function lists()
    {
        return $this->data(ExportService::getList());
    }

    /**
     * 导出日志详情
     * @return Json
     */
    public function detail()
    {
        $params = $this->getData(['id']);
        $result = ExportService::detail($params);
        return $this->data($result);
    }

    /**
     * 导出文件下载
     * @return null
     */
    public function download()
    {
        $params = $this->getData(['id']);
        return ExportService::download($params);
    }

    /**
     * 导出日志详情
     * @return Json
     */
    public function delete()
    {
        $params = $this->getData(['id']);
        $result = ExportService::delete($params);
        if(true === $result) {
            return $this->success([], '删除成功');
        } else {
            return $this->error(ExportService::getError('删除失败'));
        }
    }
}